class EventEmitter {
    constructor() {
        this.events = {}
    }
    on(event, callback) {
        this.events[event].push(callback)
    }
    emit(event, ...args) {
        this.events[event].forEach(fn => fn(...args))
    }
    off(event, callback) {
        this.events[event].filter(fn => fn !== callback)  // 注意
    }
    once(event, callback) {
        function wrapFn(...args) {
            this.off(event, wrapFn)
            callback.call(this, ...args)
        }
        this.on(evnet, wrapFn)
    }
}